package com.example.gaoyang.enums;

/**
 * 车辆出入类型枚举
 */

public enum VehicleAccessTypeEnum {
    ENTER("入口", "1"),
    EXIT("出口", "2");

    private final String name;
    private final String code;

    VehicleAccessTypeEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    /**
     * 根据code获取name
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        for (VehicleAccessTypeEnum vehicleAccessTypeEnum : values()) {
            if (vehicleAccessTypeEnum.getCode().equals(code)) {
                return vehicleAccessTypeEnum.getName();
            }
        }
        return null;
    }
}
